package com.topisv.tms.web.report;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.topisv.tms.mybatis.Pagination;
import com.topisv.tms.service.report.KpiOutOrderService;
import com.topisv.tms.vo.report.KpiReportVo;

/**
 * 
 * @author 袁晟
 * @date 2016年7月8日 下午4:34:07
 * 
 *       KPI出库订单报表
 */
@Controller
@RequestMapping(value = "/kpiOutOrder")
public class KpiOutOrderController {

    private static final Logger logger = LoggerFactory.getLogger(KpiOutOrderController.class);

    @Autowired
    private KpiOutOrderService kpiOutOrderService;

    @RequestMapping(value = "v2_query", method = RequestMethod.GET)
    public String queryInit(Model model) {
        model.addAttribute("opNameList", kpiOutOrderService.getOPName());
        return "report/kpiOutOrderReport";
    }

    /**
     * 按参数分页查询信息
     * 
     * @param paramJson
     * @return
     */
    @RequestMapping(value = "quer")
    @ResponseBody
    public Object quer(KpiReportVo vo) {
        Pagination page = null;
        try {
            page = kpiOutOrderService.getPageKpiReceive(vo);
        } catch (Exception e) {
            logger.error("KpiOutOrderController query error", e);
        }
        return page;
    }

    /**
     * 获取操作人员名称列表
     *
     * @param
     * @return
     * @throws @author
     *             yuansheng
     * @version 1.0.0
     */
    @RequestMapping(value = "querOPName")
    @ResponseBody
    public Object querOPName() {
        return kpiOutOrderService.getOPName();
    }

    /**
     * 根据参数，导出excel
     * 
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "exportExcel")
    public String exportExcel(KpiReportVo vo, HttpServletResponse response) {
        try {
            kpiOutOrderService.exportExcel(vo, response);
            return null;
        } catch (Exception e) {
            logger.error("KpiOutOrderController exportExcel error", e);
            return "error";
        }
    }

}
